#ifndef TCP_INETADDRESS_H
#define TCP_INETADDRESS_H

#include <netinet/in.h>
#include <string>

class InetAddress{
public:
    explicit InetAddress(int port = 0);

    InetAddress(std::string ip, int port);

    explicit InetAddress(const struct sockaddr_in & addr) : addr_(addr){}

    sa_family_t family() const{
        return addr_.sin_family;
    }

    std::string toIp() const;

    int toPort() const;

    const struct sockaddr * getSockAddr() const { return (struct sockaddr *)&addr_; }

private:
    struct sockaddr_in addr_;
};

#endif //TCP_INETADDRESS_H
